<?php
require_once '../core/db_abstract_model.php';


class Departamento extends db_abstract_model{
    
    public   $nIdDepartamento;
    public   $sDescripcion;
    private  $dFecha;
    private  $sUsuario;
    private  $sTerminal;

    public function get($nIdDepartamento='') {
        if (!$nIdDepartamento==''){
           $this->query="SELECT * from SCICDepartamento WHERE nIdDepartamento = '".$nIdDepartamento."'";
           $this->get_queryresults();
           if (count($this->result_rows)==1)
               {
                foreach ($this->result_rows[0] as $propiedad=>$valor)
                    {
                        $this->$propiedad=$valor;
                    }
               }
           else{
                    $this->msj=MSJ_DEPTO_FOUND;
               }
        
           }
           else{
               $this->msj=MSJ_DEPTO_UNFOUND;
           }
    }
   
    public function set($depto_data=array()) {
 
   }
    
    public function edit($depto_data=array()) {
      
    }
    
    public function delete($nIdDepartamento=''){

    }
    
    public function getdeptos($param=''){
        $this->query="SELECT nIdDepartamento,sDescripcion from SCICDepartamento";
        if($param!='')
        $this->query="SELECT nIdDepartamento,sDescripcion from SCICDepartamento Where nIdDepartamento=$param
                     UNION ALL
                     SELECT nIdDepartamento,sDescripcion from SCICDepartamento Where nIdDepartamento!=$param";
        $this->get_numqueryresults();
        $resultset=array();
        if (count($this->result_rows)>=1){
            $resultset=$this->result_rows;
        }
        else{
            $this->msj=MSJ_NODEPTO_RESULTS;
        }
        return $resultset;
    }
    
    function __construct() {
        $this->db_name='DBSCInterno';
    }
    
    function __destruct() {
        unset($this);
    }
}
?>
